package alexattar.gdxtest.screens;

import alexattar.gdxtest.DefaultActorListener;
import alexattar.gdxtest.GdxTestGame;
import alexattar.gdxtest.services.SoundManager.TyrianSound;

import com.badlogic.gdx.Screen;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;

public class MenuScreen extends AbstractScreen implements Screen {

	public MenuScreen(GdxTestGame game) {
		super(game);
	}
	
	@Override
	public void show() {
		super.show();
		
		Skin skin = super.getSkin();
		
		Table table = new Table( getSkin() );
		table.setFillParent(true);
		stage.addActor(table);
		
		TextButton startGameButton = new TextButton("Start Game", skin);
		startGameButton.addListener(new DefaultActorListener() {
			@Override
			public void touchUp(
					InputEvent event,
					float x, float y,
					int pointer,
					int button) {
				super.touchUp(event, x, y, pointer, button);
				game.getSoundManager().play(TyrianSound.CLICK);
				game.setScreen( new StartGameScreen(game) );
			}
		});
		table.add(startGameButton).size(300, 60).uniform().fill().spaceBottom(10);
		table.row();
		
		TextButton optionsButton = new TextButton("Options Game", skin);
		optionsButton.addListener(new DefaultActorListener() {
			@Override
			public void touchUp(
					InputEvent event,
					float x, float y,
					int pointer,
					int button) {
				super.touchUp(event, x, y, pointer, button);
				game.getSoundManager().play(TyrianSound.CLICK);
				game.setScreen( new OptionsScreen(game) );
			}
		});
		table.add(optionsButton).uniform().fill().spaceBottom(10);
		table.row();
		
		TextButton highScoresButton = new TextButton("High Scores", skin);
		highScoresButton.addListener(new DefaultActorListener() {
			@Override
			public void touchUp(
					InputEvent event,
					float x, float y,
					int pointer,
					int button) {
				super.touchUp(event, x, y, pointer, button);
				game.getSoundManager().play(TyrianSound.CLICK);
				game.setScreen( new HighScoresScreen(game) );
			}
		});
		table.add(highScoresButton).uniform().fill();
	}

}
